The HTTP verb POST used to access path '[my path]' is not allowed.

Posted by Jed on Stack Overflow See other posts from Stack Overflow or by Jed
Published on 2011-01-05T23:47:38Z Indexed on 2011/01/05 23:53 UTC
Read the original article Hit count: 192

Filed under:
|
|

I am receiving an error that states: "The HTTP verb POST used to access path '[my path]' is not allowed.".

The error is being caused by the fact that I am implementing an HTML form element that uses the POST method and does not explicitly define an .aspx page in its ACTION parameter.

For example:

<form action="" method="post">
  <input type="submit" />
</form>

The HTML above is on a file at "/foo/default.aspx".

Now, if the user points the URL to the root directory "foo" without specifying the aspx file (i.e. "http://localhost/foo") and then submits the form, the error "The HTTP verb POST used to access path '/foo' is not allowed." will be thrown.

However, if the user goes to "http://localhost/foo/default.aspx" and then submits the form, all goes well (even if the ACTION parameter is left empty).

Note: If I explicitly add the name of the .aspx (default.aspx) page to the ACTION parameter, no errors are thrown. So the example below works fine regardless if the user defines the name of the file in the URL or not.

<form action="default.aspx" method="post">
  <input type="submit" />
</form>

I was curious as to why the error was being thrown, so I read a Microsoft KB that states

This problem occurs because a client makes an HTTP request by sending the POST method to a static HTML page. Static HTML pages do not support the POST method.

I suppose the core of the explanation makes sense, however in my case, my form is not being sent to a static html page - it's being sent to the same page that the html form lives on (default.aspx)... this is implicit to an ACTION param that is left empty.

Is it possible to configure IIS (or otherwise) that will allow us to do form POSTing and keep the ACTION param empty?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about form